<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no">

    <title>INSPINIA | Dashboard</title>
    <link rel="stylesheet" href="../../plugins/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../css/fa.css"/>
    <link rel="stylesheet" href="../../css/icon.css"/>
    <link rel="stylesheet" href="../../css/ares_animate.min.css"/>
    <link rel="stylesheet" href="../../css/ares_hover_variant.min.css"/>
    <link rel="stylesheet" href="../../css/ares_reboot.css"/>
    <link rel="stylesheet" href="../../css/app.min.css"/>
    <link rel="stylesheet" href="../../css/iframe.css"/>
    <link rel="stylesheet" href="../../css/print.css"/>
    <style>

    </style>
</head>

<body class="print-wrap">
<button id="print-btn" class="layui-btn layui-btn-xs ares-d-print-none ares-position-absolute ares-absolute-tr-offset">打印</button>
<h3>基本信息</h3>
<div class="ares-mb emr-info"></div>
<h3>报告内容</h3>
<div>
    <div>报告类型: <span id="type"></span></div>
    <div>报告时间: <span id="datetime"></span></div>
    <div>报告描述: <span id="remark"></span></div>
</div>
<div id="report-images" class="ares-row ares-mt"></div>


<script type="text/javascript" src="../../plugins/layui/layui.js"></script>
<script type="text/javascript" src="../../aresExtends/config/layuiConfig.js"></script>
<script>
    var init;
    layui.use(['dateFilters', 'commonServices', 'mandyServices', 'qs', 'printArea'], function (dateFilters, commonServices, mandyServices, qs, printArea) {
        var emrId, reportId, is_referral_history, referralId;
        init = function () {
            var localHash = location.hash,
                queryStr = localHash.split('?')[1],
                routerParams = top.layui.routers.params,
                routerQuery = queryStr ? qs.parse(queryStr) : {};
            console.log(localHash, queryStr, routerParams, routerQuery)
            emrId = routerParams.emrId;
            reportId = routerParams.reportId;
            is_referral_history = routerQuery.isReferralHistory;
            referralId = routerQuery.referralId;
            getPatientInfo();
            loadCheckReport();
        }
        init();
        /**
         * @author: ares
         * @date: 2021/3/30 11:51
         * @description: 打印
         */
        $('#print-btn').on('click', function () {
            $('.print-wrap').printArea();
        })

        /**
         * @author: ares
         * @date: 2021/3/30 11:08
         * @description: 加载报告
         */
        function loadCheckReport() {
            mandyServices.mandy_get_inspection_report(reportId, emrId, is_referral_history).then(function (res) {
                var data = res.data;
                $('#type').text(data.type);
                $('#datetime').text(dateFilters.dateTimeFormat(data.check_time));
                $('#remark').text(data.remark);
                renderImages(data.images || []);
            });
        }

        /**
         * @author: ares
         * @date: 2021/3/30 10:24
         * @description: 渲染报告图片
         * @param{array} images
         */
        function renderImages(images) {
            var $reportImages = $('#report-images'),
                $fragment = $(document.createDocumentFragment());
            if (!Array.isArray(images) || !images.length) {
                $reportImages.empty();
                return;
            }
            $.each(images, function (index, image) {
                $fragment.append('<div class="ares-col-sm-6 ares-col-md-4 ares-col-lg-3">' +
                    '<div class="ares-position-relative ares-p ares-border">' +
                    '<img class="ares-w-100" src="' + image + '" alt=""/>' +
                    '</div>' +
                    '</div>'
                )
            })
            $reportImages.empty().append($fragment);
        }

        /**
         * @author: ares
         * @date: 2021/3/10 10:49
         * @description: 获取患者基本信息
         */
        function getPatientInfo() {
            commonServices.getEmrInfoService(emrId, null, null, $('.emr-info'))
        }
    })
</script>
</body>
</html>



